package cn.tedu.tmall.passport.dao.repository.impl;

import cn.tedu.tmall.passport.dao.mapper.UserMapper;
import cn.tedu.tmall.passport.dao.repository.IUserRepository;
import cn.tedu.tamll.common.pojo.po.PermissionPO;
import cn.tedu.tamll.common.pojo.po.UserPO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import java.util.Arrays;
import java.util.List;

@Repository
public class UserRepository implements IUserRepository {
    @Autowired
    private UserMapper mapper;
    @Override
    public UserPO getUserInfoByUsername(String username) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("username",username);
        return mapper.selectOne(queryWrapper);
    }

    @Override
    public List<PermissionPO> getAllPermissions(Long id) {
            PermissionPO articleAdd = new PermissionPO();
            articleAdd.setAuthority("/articles/add");
//    [{authority:'/articles/add'},{authority:'/articles/detail'}]
            PermissionPO articleDetail = new PermissionPO();
            articleDetail.setAuthority("/articles/detail");

            return Arrays.asList(articleDetail,articleAdd);
    }
}
